//
//  XZMachineModeCell.m
//  Teecloud
//
//  Created by PC on 2018/11/22.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZMachineModeCell.h"
#import "XZSignQrcodeList.h"
@interface XZMachineModeCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;

@end
#define KTrainColor [UIColor colorWithHexString:@"#FF9900" andAlpha:1.0]
@implementation XZMachineModeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(XZSignQrcodeList *)model{
    _model = model;
    self.nameLabel.text = model.Name;
    self.timeLabel.text = [NSString stringWithFormat:@"【%@】",model.StartEndTimeName];
    //都显示
    if (model.IsNeedSignIn && model.IsNeedSignOut) {
        NSString *totalNum = [NSString stringWithFormat:@"%@",model.Count];
        NSString *signInNum = [NSString stringWithFormat:@"%@",model.SignCount];
        NSString *signOutNum = [NSString stringWithFormat:@"%@",model.OutCount];
        NSString *string = [NSString stringWithFormat:@"共 %@ 人，签到 %@ 人，签退 %@ 人",model.Count,model.SignCount,model.OutCount];
        NSMutableAttributedString *originalAttributedString = [[NSMutableAttributedString alloc] initWithString:string];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [originalAttributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
        
        [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(2, totalNum.length)];
        
         [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(8+totalNum.length, signInNum.length)];
        
         [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(14+totalNum.length+signInNum.length, signOutNum.length)];
        self.countLabel.attributedText = originalAttributedString;
    }
    //都没有的时候
    if (!model.IsNeedSignIn && !model.IsNeedSignOut) {
        NSString *totalNum = [NSString stringWithFormat:@"%@",model.Count];
        NSString *string = [NSString stringWithFormat:@"共 %@ 人",model.Count];;
        NSMutableAttributedString *originalAttributedString = [[NSMutableAttributedString alloc] initWithString:string];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [originalAttributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
        [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(2, totalNum.length)];
        self.countLabel.attributedText = originalAttributedString;
    }
    //没签退
    if (model.IsNeedSignIn && !model.IsNeedSignOut) {
        NSString *totalNum = [NSString stringWithFormat:@"%@",model.Count];
        NSString *signInNum = [NSString stringWithFormat:@"%@",model.SignCount];
        NSString *string = [NSString stringWithFormat:@"共 %@ 人，签到 %@ 人",model.Count,model.SignCount];
        NSMutableAttributedString *originalAttributedString = [[NSMutableAttributedString alloc] initWithString:string];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [originalAttributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
        [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(2, totalNum.length)];
        [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(8+totalNum.length, signInNum.length)];
        self.countLabel.attributedText = originalAttributedString;
    }
    
    //没签到
    if (!model.IsNeedSignIn && model.IsNeedSignOut) {
        NSString *totalNum = [NSString stringWithFormat:@"%@",model.Count];
        NSString *signOutNum = [NSString stringWithFormat:@"%@",model.OutCount];
        NSString *string = [NSString stringWithFormat:@"共 %@ 人，签退 %@ 人",model.Count,model.OutCount];
        NSMutableAttributedString *originalAttributedString = [[NSMutableAttributedString alloc] initWithString:string];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [originalAttributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
        [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(2, totalNum.length)];
        [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(8+totalNum.length, signOutNum.length)];
        self.countLabel.attributedText = originalAttributedString;
    }
}
- (void)textAttributedString:(NSString *)string scoreString:(NSString *)scoreString label:(UILabel *)label{
    NSMutableAttributedString *originalAttributedString = [[NSMutableAttributedString alloc] initWithString:string];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [originalAttributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
    [originalAttributedString addAttribute:NSForegroundColorAttributeName value:KTrainColor range:NSMakeRange(3, scoreString.length)];
    label.attributedText = originalAttributedString;
}
@end
